package com.zzl.admin.controller.secKill;

import com.zzl.admin.service.sceKill.SecKillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description：秒杀Controller
 * Created by 朱正磊 on 2019-05-12 13:30
 */
@RestController
@RequestMapping("/secKill")
@Slf4j
public class SecKillController {

    @Autowired
    //@Qualifier("secKillServiceImpl")
    private SecKillService secKillService;

    /**
     * description：查询秒杀活动特价商品的信息
     * user 朱正磊
     * time 2019-05-12 13:33
     * @param productId 商品ID
     * @return 返回秒杀活动特价商品的信息
     */
    @RequestMapping("/query/{productId}")
    public String query(@PathVariable("productId") String productId) {
        return secKillService.querySecKillProductInfo(productId);
    }

    /**
     * description：秒杀，抢到了会返回商品剩余的库存量，没有抢到的话会返回提示信息"哎呦喂，人也太多了吧，请换个姿势再试试~~~"
     * user 朱正磊
     * time 2019-05-12 13:37
     * @param productId 商品ID
     * @return 返回秒杀活动特价商品的信息
     */
    @RequestMapping("/order/{productId}")
    public String secKill(@PathVariable("productId") String productId) {
        log.info("@secKill request, productId: " + productId);
        secKillService.orderProductMockDiffUser(productId);
        return secKillService.querySecKillProductInfo(productId);
    }

}
